package priv.yiyuan.example.design.factory;

import priv.yiyuan.example.design.device.PlaybackDevice;
import priv.yiyuan.example.design.device.SpeakerSystem;
import priv.yiyuan.example.design.player.MediaPlayer;
import priv.yiyuan.example.design.player.MoviePlayer;
import priv.yiyuan.example.design.player.MusicPlayer;

/**
 * 音响播放器工厂
 * <p>
 * 工厂方法模式(具体创建者)
 */
public class SpeakerPlayerFactory implements MediaPlayerFactory {

    private PlaybackDevice speakerSystem;

    public SpeakerPlayerFactory(String name) {
        this.speakerSystem = new SpeakerSystem(name);
    }

    @Override
    public MediaPlayer createMoviePlayer() {
        System.out.println("为扬声器创建电影音频播放器.");
        return new MoviePlayer(speakerSystem);
    }

    @Override
    public MediaPlayer createMusicPlayer() {
        System.out.println("为扬声器创建音乐播放器.");
        return new MusicPlayer(speakerSystem);
    }

    @Override
    public MediaPlayer createImagePlayer() {
        System.out.println("扬声器无法播放图片信息.");
        return null;
    }
}
